﻿using System;
using System.Text;
using UnityEngine;

namespace com.tdb.foundation
{
    public class TextUtil
    {
        public static string SetColorString(string orginString, Color color)
        {
            return string.Format("<color=#{0}>{1}</color>", Color2String(color), orginString);
        }

        public static string Color2String(Color color)
        {
            int r = (int) (color.r * 255);
            int g = (int) (color.g * 255);
            int b = (int) (color.b * 255);
            int a = (int) (color.a * 255);
            return string.Format("{0:X2}{1:X2}{2:X2}{3:X2}", r, g, b, a);
        }
    }
}